package com.edu.exam.entity.assessment;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Version;
import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.edu.exam.enums.assessment.AssessmentMethod;
import com.edu.exam.enums.assessment.AssessmentTiming;
import com.edu.exam.enums.assessment.SubmissionMethod;

/**
 * 考核项目实体类
 * 所属模块：B-04 考核方案管理模块
 * 对应数据库表：assessment_plan_item
 *
 * 根据B-04考核方案管理模块设计文档实现
 * 管理考核方案中的具体考核项目，包括项目名称、考核方式、权重、时机等信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class AssessmentPlanItem {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 关联方案ID
     */
    @Column(name = "scheme_id", nullable = false)
    private Long schemeId;

    /**
     * 方案编码
     */
    @Column(name = "scheme_code", length = 50)
    private String schemeCode;

    /**
     * 项目名称
     */
    @Column(name = "name", nullable = false, length = 200)
    private String name;

    /**
     * 项目描述
     */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    /**
     * 考核方式
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "method", nullable = false, length = 50)
    private AssessmentMethod method;

    /**
     * 权重
     */
    @Column(name = "weight", precision = 5, scale = 2)
    private BigDecimal weight;

    /**
     * 最高分数
     */
    @Column(name = "max_score", nullable = false)
    private Integer maxScore;

    /**
     * 考核时机
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "timing", nullable = false, length = 20)
    private AssessmentTiming timing;

    /**
     * 计划标识
     */
    @Column(name = "plan_flag", nullable = false)
    private Boolean planFlag;

    /**
     * 考核时长（分钟）
     */
    @Column(name = "duration_minutes")
    private Integer durationMinutes;

    /**
     * 考核地点
     */
    @Column(name = "location", length = 200)
    private String location;

    /**
     * 考核要求
     */
    @Column(name = "requirements", columnDefinition = "TEXT")
    private String requirements;

    /**
     * 评分标准
     */
    @Column(name = "grading_criteria", columnDefinition = "TEXT")
    private String gradingCriteria;

    /**
     * 参考材料
     */
    @Column(name = "reference_materials", columnDefinition = "TEXT")
    private String referenceMaterials;

    /**
     * 考核工具
     */
    @Column(name = "assessment_tools", length = 500)
    private String assessmentTools;

    /**
     * 实施教师
     */
    @Column(name = "instructor", length = 100)
    private String instructor;

    /**
     * 考核周次
     */
    @Column(name = "assessment_week")
    private Integer assessmentWeek;

    /**
     * 考核日期
     */
    @Column(name = "assessment_date")
    private LocalDateTime assessmentDate;

    /**
     * 补考机会
     */
    @Column(name = "retake_opportunities")
    @Builder.Default
    private Integer retakeOpportunities = 0;

    /**
     * 迟交方式
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "submission_method", length = 50)
    private SubmissionMethod submissionMethod;

    /**
     * 迟交截止时间
     */
    @Column(name = "submission_deadline")
    private LocalDateTime submissionDeadline;

    /**
     * 评分权重分布
     */
    @Column(name = "weight_distribution", columnDefinition = "TEXT")
    private String weightDistribution;

    /**
     * 备注
     */
    @Column(name = "remarks", length = 1000)
    private String remarks;

    /**
     * 创建时间
     */
    @Column(name = "create_time", nullable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除者ID
     */
    @Column(name = "deleter_id")
    private Long deleterId;
}